home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Technology Seed / ADC Seed CD - July 1999.toast / USB / Mac OS USB DDK v1.2 / Examples / USBSampleStorageDriver / SampleStorageDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-15  |  3.9 KB  |  147 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SampleStorageDriver.h
  3.  
  4.     Contains:    All definitions used by the Sample Storage Driver
  5.  
  6.     Version:    1.1
  7.  
  8.     Copyright:    © 1998-1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12.  
  13. #ifndef __SAMPLESTORAGEDRIVER__
  14. #define __SAMPLESTORAGEDRIVER__
  15.  
  16. #include <USB.h>
  17. #include "SampleStorageDriverAPI.h"
  18.  
  19.  
  20. #if DEBUG
  21. #define IF_DEBUG(x)    x
  22. #else
  23. #define IF_DEBUG(x)
  24. #endif
  25.  
  26. #define kStrStorageClass    "\pStorageClass: "
  27.  
  28. #define kStorageRetryCount    5
  29. #define kMaxTransitions        1
  30. #define kIntDataSize        8
  31. #define kStatusSize            2        // USB Status
  32. #define kUSBMaxBulkTransfer    0x200000        // Max transfer is 2MB
  33.  
  34. // These states are used by StorageDeviceInitiateConfiguration
  35. enum driverConfigStates
  36. {
  37.     kUndefined =                0,
  38.     
  39.     kSetConfig,
  40.     kGetFullConfiguration,
  41.     kFindStorageInterface,
  42.     kStorageConfigureInterface,
  43.     
  44.     kNewInterfaceRef,
  45.     kStorageFindInterruptPipe,
  46.     kStorageFindBulkInPipe,
  47.     kStorageFindBulkOutPipe,
  48.     kStorageReadInterrupt,
  49.     
  50.     kStorageExecuteCommand,                    // Begin execution of user command
  51.     kStorageExecuteCommandCompletion,        // Complete the user command
  52.     kStorageBulkIOComplete,                    // Complete the bulk read
  53.     kStorageGetStatus,                        // Complete the GetStatus request
  54.     kStorageGetStatusBulkRead,                // Get the status data
  55.     
  56.     kNilCompletion,
  57.     
  58.     kReturnFromDriver =         0x1000,
  59.     kRetryTransaction =         0x2000,
  60.     kAsyncTransaction =         0x4000,
  61.     kCompletionPending =         0x8000
  62. };
  63.  
  64. // Structure for the global PB's
  65. struct StorageClassTransactionPB {
  66.     USBPB                usbPB;
  67.     UInt8                cdb[kCDBSize];
  68.     UInt32                        currentState;
  69.     Boolean                        busy;
  70.     UInt32                        flags;                // Flags from StorageClassRequest pb
  71.     StorageExecuteCommandPBPtr    userPBPtr;
  72. };
  73. typedef struct StorageClassTransactionPB    StorageClassTransactionPB;
  74. typedef    StorageClassTransactionPB             *StorageClassTransactionPBPtr;
  75.  
  76.  
  77. struct StorageClassInfo {
  78.     USBPB                             usbPB;                    // Configuration block
  79.     
  80.     // Device info
  81.     UInt8                            firmwareVersion[2];
  82.     
  83.     // Interrupt pipe
  84.     USBPipeRef                         interruptPipeRef;        // USB pipe reference
  85.     UInt8                            interruptReport[kIntDataSize];
  86.     
  87.     //    mandatory bulk in pipe
  88.     USBPipeRef                         readPipeRef;            // USB pipe reference
  89.     
  90.     //    mandatory bulk out pipe
  91.     USBPipeRef                         writePipeRef;            // USB pipe reference
  92.  
  93.     //    device: configuration and interface details
  94.     USBDeviceRef                    interfaceRef;            // USB device reference
  95.     USBDeviceRef                    deviceRef;                // USB device reference
  96.     USBConfigurationDescriptorPtr     pFullConfigDescriptor;
  97.     USBConfigurationDescriptor        partialConfigDescriptor;
  98.     
  99.     USBInterfaceDescriptor            interfaceDescriptors[32];
  100.     USBInterfaceRef                    interfaceRefArray[32];
  101.     USBRqIndex                        interfaceCount;
  102.     USBRqIndex                        interfaceIndex;
  103.     
  104.     UInt32                            interfaceNumber;
  105.  
  106.     USBDeviceDescriptor             deviceDescriptor;        // copy for local reference
  107.     USBInterfaceDescriptorPtr        pInterfaceDescriptor;    // copy for local reference
  108.  
  109.     //    class driver async transactions
  110.     SInt32                            transDepth;                // don't nest transactions
  111.     SInt32                             retryCount;                // automatically retry transactions
  112.     UInt32                            currentState;            // State machine state
  113. };
  114. typedef struct StorageClassInfo    StorageClassInfo;
  115. typedef    StorageClassInfo         *StorageClassInfoPtr;
  116.  
  117.  
  118. struct StorageClassStatusPB {
  119.     USBPB                usbPB;
  120.     Boolean                busy;
  121.     StorageStatusPBPtr    userPBPtr;
  122.     UInt8                status[kStatusSize];
  123. };
  124. typedef struct StorageClassStatusPB    StorageClassStatusPB;
  125. typedef    StorageClassStatusPB         *StorageClassStatusPBPtr;
  126.  
  127.  
  128. struct StorageClassControlPB {
  129.     USBPB                usbPB;
  130.     Boolean                busy;
  131.     StorageControlPBPtr    userPBPtr;
  132. };
  133. typedef struct StorageClassControlPB    StorageClassControlPB;
  134. typedef    StorageClassControlPB             *StorageClassControlPBPtr;
  135.  
  136.  
  137. // Function protoypes
  138. extern OSStatus    StorageClassDriverInitialize(void);
  139.  
  140. extern OSStatus StorageClassDriverControl(UInt32 theControlSelector, void *theControlData);
  141.  
  142. extern OSStatus StorageClassDriverStatus(UInt32 theInfoSelector, void *theInfo);
  143.  
  144. extern OSStatus StorageClassDriverExecuteCommand(StorageExecuteCommandPBPtr storageExecuteCommandPBPtr);
  145.  
  146.  
  147. #endif /* __SAMPLESTORAGEDRIVER__ */